package com.fire.control.system.statics;

import com.fire.control.system.support.protocol.comman.ResponseProtocol;
import com.fire.control.system.support.util.XdaoDate;

//这个不需要做接口
public enum ResponseMessage {
	
	//参考http://blog.csdn.net/chenyongkai1/article/details/52495101
	CODE_200(200,"请求成功！",true),
	CODE_204(204,"请求成功,无返回数据！",true),
	CODE_400(400,"请求参数错误！",false),
	CODE_401(401,"未授权！",false),
	CODE_DATAISNOTNULL(1000,"本月已排班",true),
	CODE_USERISNOTEXIST(1001,"用户不存在",true),
	CODE_DEFINED(0,"未知错误",false);
	
	private int code;
	private String message;
	private boolean isSuccess;
	
	private ResponseMessage(int code,String message,boolean isSuccess){
		this.code = code;
		this.message = message;
		this.isSuccess = isSuccess;
	}
	
	
	public int getCode() {
		return code;
	}


	public String getMessage(){
		return this.message;
	}
	public boolean isSuccess(){
		return this.isSuccess;
	}
	
	public ResponseProtocol messageToProtocol(ResponseProtocol protocol){
		protocol.setCode(this.code);
		protocol.setIsSuccess(this.isSuccess);
		protocol.setMessage(this.message);
		protocol.setDate(new XdaoDate());
		return protocol;
	}


	public void setMessage(String message) {
		this.message = message;
	}
}
